<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>报销申请</title>
<link rel="stylesheet" href="Css/RAcss.css" type="text/css"></link>
</head>
<body>
	<div id="main">
		<p id="top">工作台 > 报销单 > 报销申请</p>
		<div class="show">
			<form id="form" action="" >
				<div id="apply1">
					<h3>报销申请单</h3>
					<p>申请人</p>
					<input type="text" ><br/>
					<p>事由</p>
					<textarea style="resize:none;"></textarea><br/>
					<p>审批人</p>
					<input type="text" ><br/>
				</div>
				
				<div id="apply2" style="display:none;">
					<h3>报销明细</h3>
					<table>
						<tr>
							<td>交通</td>
							<td>伙食</td>
							<td>住宿</td>
							<td>参会</td>
							<td>其他</td>
						</tr>
						<tr>
							<td><input id="t" type="text" value="0">元</td>
							<td><input id="f" type="text" value="0">元</td>
							<td><input id="r" type="text" value="0">元</td>
							<td><input id="m" type="text" value="0">元</td>
							<td><input id="o" type="text" value="0">元</td>
						</tr>
						<tr>
							<td>总金额</td>
							<td  colspan="4"><input id="total" type="text" value="0">元</td>
						</tr>
						
						<tr>
							<td colspan="5">
							<input type="file" id="upload" onchange="getFile(value)" multiple>
							</td>
						</tr>				
					</table>
					<input type="text" id="doc">	
				</div>
				
			</form>
			<div>
				<button onclick="todetails()">添加明细</button>
				<button onclick="toBF()">返回</button>
				<button onclick="toApply()">确认申请</button>
			</div>
		</div>
	</div>
	
	<script>
	
	var total = document.getElementById("total");
	total.addEventListener("click", function(){
		var t=document.getElementById("t").value;
		var r=document.getElementById("r").value;
		var f=document.getElementById("f").value;
		var m=document.getElementById("m").value;
		var o=document.getElementById("o").value;
		var strings = [t,r,f,m,o];
		var all = eval(strings.join("+"));
		document.getElementById("total").value = all;
	 
	});
	
	function getFile(value){
        var doc = document.getElementById('doc');// 获取文本框dom        
        var upload = document.getElementById('upload');// 获取上传控件dom        
        var fileName = upload.files[0].name;// 获取文件名
       	var filePath = upload.value; // 获取文件路径
        doc.value = upload.value;// 将文件名载入文本框
        console.log(fileName);
        console.log(filePath);
    }
	
	function todetails(){
		document.getElementById("apply2").style.display="block";
	}
	
	function toBF(){
		window.location.href="ReimburseForm.jsp";
	}
	
	function toApply(){
		
	}
	
	</script>

</body>
</html>